package com.loong.common.mvc;

import com.loong.common.executor.HandlerExecutor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

import javax.annotation.Resource;
import java.beans.PropertyEditorSupport;
import java.util.Date;

public class BaseController {

    @Resource
    protected HandlerExecutor handlerExecutor;

    /**
     * Date类型 要求前端传递时间是时间戳
     * @param binder
     */
    @InitBinder
    protected void initBinder(WebDataBinder binder) {
        binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
            @Override
            public void setAsText(String value) {
                setValue(new Date(Long.valueOf(value)));
            }
        });
    }

}
